package com.wica.adapter;

import com.wica.view.ELTopRated;

import android.content.Context;
import android.preference.PreferenceManager;
import android.util.Log;

	public class ELATopRated extends EfficientListAdapter{

	// *************** Constants ************** //  
    public static final String TAB_PREFERENCES_SEARCH_1 = "top_rated_time";
    public static final String TAB_PREFERENCES_SEARCH_2= "top_rated_numberOfResults";
    // Set up a random unique ID for message handler
    public static final int GUIUPDATEIDENTIFIER = 12345;

    // *************** Attributes ************************* //
	/* Attributes: (regarding FaceTube WebService) */
    /** numberOfResults: Integer -- 0..30 (regarding FaceTube WebService)**/
	private Integer numberOfResults;
	/** 	time: String 			(regarding FaceTube WebService)
	 * 								-- All Time:   "all_time"  ""  null
	 * 								-- This Month: "this_month"
	 * 								-- This Week:  "this_week"
	 * 								-- Today:	   "today"
	 **/
	private String time;
	
	
	public ELATopRated(ELTopRated list) {
		super(list);	
		this.list=list;
		this.adapter=this;
		this.numberOfResults=Integer.valueOf(PreferenceManager.getDefaultSharedPreferences((Context)list).getString("top_rated_numberOfResults", "7"));
		this.time=PreferenceManager.getDefaultSharedPreferences((Context)list).getString("top_rated_time", "this_week");
		getListOfVideosThread();
	}//ELATopRated method	

    protected void checkPreconditions() {
		if (time.compareTo("all_time")!=0 && time.compareTo("")!=0 && time!=null && time.compareTo("this_month")!=0 && time.compareTo("this_week")!=0 && time.compareTo("today")!=0){
			Log.e(LOG_TAG, "Not a valid \"time\" parameter when calling "+"EfficientListAdapter"+"->"+"getMostViewed"+"\nIt should be: \"all_time\",\"\",null,\"this_month\",\"this_week\",\"today\"");			System.exit(-1);
		}		
	}

	protected void getListOfVideosMethod() {
    	super.getListOfVideosMethod();
		listOfMovies = fts.getTopRated(numberOfResults, time);
	}// getListOfVideosMethod method
    
    // *************** Set methods ************** //  
	public void setNumberOfResults(Integer numberOfResults){
    	this.numberOfResults = numberOfResults;
    }//setNumberOfResults	
    
    public void setTime(String time){
    	this.time = time;
    }//setTime
    
}// ELATopRated class
